package net.sxnic.ugr.group.dao;

import java.util.List;

import net.sxinfo.core.spring25.HibernateDao;
import net.sxnic.ugr.group.Group;
import net.sxnic.ugr.role.Role;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

@Repository("groupDao")
public class HibernateGroupDao extends HibernateDao<Group, String> implements
		GroupDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<Group> getGroupsInRole(Role role) {
		Query query = getCurrSession().createQuery("from Group as d where ? in elements(d.roles)");
		query.setParameter(0, role);
		return query.list();
	}

}
